<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>05.form_fields | KnockOut</title>
  <script src="../assets/knockout-3.5.1.js"></script>
</head>
<body>

  <ul data-bind="foreach: people">
    <li>
      <span data-bind="text: $data"></span>
      <button data-bind="click: $parent.removePerson">Remove</button>
    </li>
  </ul>

  <script type="text/javascript">
    function MyViewModel() {
      var self = this;
      self.people = ko.observableArray(["张三", "李四", "王五"]);
      self.removePerson = function(person) {
        self.people.remove(person);
      };
    }

    ko.applyBindings(new MyViewModel());
  </script>
    
</body>
</html>
